package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.JavaBean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Auther:Liu
 * @Testname:secondcontroller
 * @Date:2025/7/30 15:33
 */
@Slf4j
@Controller
@RequestMapping("/second")
public class secondcontroller {

    @RequestMapping("/a")
    public String a(String name) {
        log.info("用户访问了SecondController的a方法");
        log.info("name:{}", name);
        return "a";
    }

    @RequestMapping("/b")
    public String b(@RequestParam(name="page",defaultValue = "1") int p) {
        log.info("用户访问了SecondController的b方法");
        log.info("页码:{}", p);
        return "b";
    }

    @RequestMapping("/c")
    public String c(String name,int age,char gender) {
        log.info("用户访问了SecondController的c方法");
        log.info("name:{},age:{},gender:{}", name,age,gender);
        return "a";
    }

    @RequestMapping("/d1")
    public String d1(User user) {
        log.info("用户访问了SecondController的d1方法");
        log.info("user:{}", user);
        return "a";
    }

    @RequestMapping("/d2")
    public String d2(@RequestBody User user) {
        log.info("用户访问了SecondController的d2方法");
        log.info("user:{}", user);
        return "a";
    }
}
